package com.walle.rabbitservice.conf;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhangjiapeng
 * @Package com.walle.rabbitservice.conf
 * @Description: ${todo}
 * @date 2018/12/27 10:53
 */
@Configuration
public class MailQueueConfig {


    /**
     * 邮件队列
     */
    public static final String MAIL_QUEUE = "walle.mail.queue";

    /**
     * 邮件exchange
     */
    public static final String MAIL_EXCHANGE = "walle.mail.exchange";

    /**
     * 邮件exchange
     */
    public static final String MAIL_BINDING = "walle.mail.binding";

    @Bean
    public DirectExchange mailExchange(){
        return new DirectExchange(MAIL_EXCHANGE,true,false,null);
    }

    @Bean
    public Queue  mailQueue(){
        return new  Queue(MAIL_QUEUE,true,false,false,null);
    }

    @Bean
    public Binding mailBinding(){
        return BindingBuilder.bind(mailQueue()).to(mailExchange()).with(MAIL_BINDING);
    }


}
